; This file is: dInterp.txt -- interpreter and compiler ; Mon Apr 25, 1988 15:11:43 macros ; Wed Apr 27, 1988 12:30:07 v 1.4 ; Thu Jul 04, 1991 05:20:00 add open control key ; Sat Aug 08, 1992 19:07:00 add floating point numbers ; Fri May 28, 1993 22:54:00 add \ inKey: ; ( key.data -- ) BTST #0,evtMeta(A0) ; is the command key down? BEQ.S @0 CMPI.B #'v',1(PS) ; is the key 'v'? BNE.S @4 ; if so then ADDQ #2,PS ; drop the ASCII and ... JMP paste-base(BP) ; ... interpret from clipboard @4: CMPI.B #'o',1(PS) ; is the key 'o'? BNE.S @0 ; if not skip ahead. ADDQ #2,PS JMP open-base(BP) ; get and interpret file @0: JSR TextNormal-base(BP) ; set font, mode and size _ObscureCursor ; hide the mouse cursor JSR NoCurs-base(BP) ; erase the cursor MOVE (PS)+,D0 ; retrieve the key data CMPI.B #CR,D0 ; is the character a CR BEQ.S Interpret ; if so: interpret the line CMPI.B #BS,D0 ; is the character a backspace? BNE.S @1 TST.B Counter ; rubout the previous character BLE.S @3 ; if count > 0 then SUBQ.B #1,Counter ; decrement count MOVE.B #BL,0(IS,Counter) ; in buffer and ... JSR doDel-base(BP) JSR Space-base(BP) ; on terminal JSR doDel-base(BP) BRA.S @3 @1: CMPI.B #80,Counter ; is the buffer full BEQ.S @2 ; then just emit it MOVE.B D0,0(IS,Counter.W) ; stash the char into the buffer ADDQ #1,Counter ; increment char count @2: JSR EmitCode-base(BP) ; emit the character @3: RTS Interpret: ; interpret a line of code JSR doCR-base(BP) ; emit the CR MOVE.B #0,1(IS,Counter.W) ; plant a null in the buffer Main: JSR token-Base(BP) ; get the next word MOVE Dict,-(PS) ; push pointer to last name JSR search-Base(BP) ; find current token in dictionary TST (PS)+ ; found NOT IF, BEQ.S TestNum ; ... assume its a number BCLR #7,fimmed-base(BP) ; ELSE, immediate? IF BNE.S GoDo ; ... do it TST.B fcolon-base(BP) ; ELSE, compiling? NOT IF, BEQ.S GoDo ; ... do it BCLR #7,fmacro-base(BP) ; ELSE, macro? IF BNE.S domc JSR compile-base(BP) ; ELSE, compile a JSR to it BRA.S Main godo: JSR execute-base(BP) JSR StkChk-base(BP) BRA.S Main domc: JSR mcomp-base(BP) BRA.S Main TestNum: ; Test the token for integer or floating point numberness. JSR here-base(BP) ; get the relative address of token JSR number-base(BP) ; convert it to a value, if posible TST (PS)+ ; was it? BEQ.S testfloat ; if not, test for floating point TST.B fcolon-base(BP) ; else, are you compiling? BEQ.S Main ; if not, leave it on the stack JSR Literal-base(BP) ; else, compile it as a literal BRA.S Main ; then, get on with it TestFloat: ; It's not an integer, try floating point. BCLR #7,fneg-base(BP) ; Is it a negative number? BEQ.S @0 MOVE.B #$2D,1(A2) ; put in a negative sign @0: MOVE.L A2,-(PS) JSR fnum-base(BP) ; do the conversion (handles error) TST.B fcolon-base(bp) ; if compiling, leave ... BEQ.S Main ; ... it on the stack. JSR flit-base(BP) ; else flit it BRA.S Main ; ----- Dictionary follows ---------